function element_theme_refresh(element, oldTheme, newTheme) {
	/* Update the page's new data theme. */
	if ($(element).attr('data-theme')) {
		$(element).attr('data-theme', newTheme);
	}
	if ($(element).attr('class')) {
		/* Theme classes end in "-[a-z]$", so match that */
		var classPattern = new RegExp('-' + oldTheme + '$');
		newTheme = '-' + newTheme;
		var classes = $(element).attr('class').split(' ');
		for ( var key in classes) {
			if (classPattern.test(classes[key])) {
				classes[key] = classes[key].replace(classPattern, newTheme);
			}
		}
		$(element).attr('class', classes.join(' '));
	}
}
$('.jqm-page').bind('refresh', function(e, newTheme) {
	/* Default to the "a" theme. */
	var oldTheme = $(this).attr('data-theme') || 'a';
	newTheme = newTheme || 'a';

	$.mobile.page.prototype.options.theme = newTheme;
	$.mobile.page.prototype.options.headerTheme = newTheme;
	$.mobile.page.prototype.options.contentTheme = newTheme;
	$.mobile.page.prototype.options.footerTheme = newTheme;

	element_theme_refresh($(this), oldTheme, newTheme);
	$(this).find('[data-role="content"]').each(function() {
		element_theme_refresh($(this), oldTheme, newTheme);
	});
	$(this).find('[data-role="header"]').each(function() {
		element_theme_refresh($(this), oldTheme, newTheme);
	});
});
// $('#first-content a').live('tap', function() {
// $('#forth a').live('tap', function() {
$('#themeList a').live('tap', function() {
	var newTheme = $(this).attr('theme');
/*	$('#current-theme').text('Current Theme: ' + newTheme);*/
	window.localStorage.setItem("theme", newTheme)
	$('.jqm-page').trigger('refresh', newTheme);
	// $.mobile.changePage("#first");
	
	$.mobile.changePage("index.html", {
		transition : "none"
	});

});
